# -*- cperl -*-
{
    my $expect = <<__END_EXPECT;
--------------------------------------------------
test-echo-off(uoo)
echo test-echo-on"(uoo)"
test-echo-on(uoo)
test-echo ---- done --------------------
dollar-sign: \$
test-dollar-sign ---- done --------------------
check:(baz):baz
wildcard-more: gen/gen_actions.pir gen/gen_builtins.pir gen/gen_grammar.pir
test-wildcard-more ---- done --------------------
test-wildcard ------------------------------
wildcard: uoo src/constants.pir src/database.pir test-wildcard-more
test-wildcard ---- done --------------------
text foo.txt
foo.xxx <- foo.txt
afoo in foo bar
bara in foo bar
test-variable-target-name ---- done --------------------
prerequsites <- uoo test-echo test-dollar-sign test-order-only test-wildcard test-variable-target-name
prerequsites ---- done --------------------
goal <- prerequsites(all: prerequsites)
__END_EXPECT
    ;
    #pop @result; ## pop the last line "smart: Done, # targets updated"
    my @r;
    do { push @r, $_ if !m/^smart:.+$/ } for @result;
    #my $result = join '', @result;
    #$check_result = $result eq $expect;
    my @expect = split "\n", $expect;
    my $na = join '', grep { !m/^(wildcard-more|wildcard).*?:/ } @r;
    my $nb = join "\n", grep { !m/^(wildcard-more|wildcard).*?:/ } @expect;
    $nb .= "\n";
    $check_result = $na eq $nb;
    #print $na, "\n";
    #print $nb, "\n";
    goto out unless $check_result;
    my @a = grep { m/^(wildcard-more|wildcard).*?:/ } @r;
    my @b = grep { m/^(wildcard-more|wildcard).*?:/ } @expect;
    for my $a (@a) {
        my ( $pre, $aitems ) = $a =~ m/^(.+?):(.+?)$/; #$
        for my $b (@b) {
            $b =~ m/^(.+?):(.+?)$/; #$
            if ( $pre eq $1 ) {
                $a = join " ", sort split " ", $aitems;
                $b = join " ", sort split " ", $2;
                do {
                    print "\n";
                    print "  expecting: '$b'\n";
                    print "  result   : '$a'\n";
                    goto out_fail;
                } unless $a eq $b;
            }
        }
    }
  out_ok:
    $check_result = 1;
    goto out;
  out_fail:
    $check_result = 0;
    goto out;
  out:
    print "";
}
